package com.henu.rescue.mapper;

import com.henu.rescue.entity.Complain;
import com.henu.rescue.entity.VO.ComplainVO;
import com.henu.rescue.entity.VO.StandardNameComplainCount;
import com.henu.rescue.utils.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ComplainMapper {

    //新增一个投诉
    Integer addComplain(Complain complain);


    //通过标准id获取标准名字
    String getStandardName(Integer standardId);

    List<ComplainVO> selectComplainInfoByPage(Page<ComplainVO> page);

    int getCountByPage(Page<ComplainVO> page);

    Integer updateStatus(Integer comId);

    @Select("SELECT st.standard_name AS standardName, COUNT(c.com_id) AS complainCount " +
            "FROM tab_standard_type st " +
            "LEFT JOIN tab_complain c ON st.standard_id = c.standard_id " +
            "GROUP BY st.standard_id, st.standard_name " +
            "ORDER BY complainCount DESC")
    List<StandardNameComplainCount> getComplaintCountByStandard();

    Integer getCount();

    Integer selectCountByOrderIdAndStandId(Complain complain);

    Integer update(ComplainVO complainVO);

    Complain getComplainById(Integer id);
}
